#pragma once
#include <iostream>
#include <string>
    enum { // 日志等级
        Info,
        Debug,
        Waring,
        Error,
        Fatal
    };
    static std::string TimeStampToLocalTime(time_t currtime) {                                                                                                                                                                          
        struct tm *curr = localtime(&currtime);
        char time_buffer[128];
        snprintf(time_buffer, sizeof(time_buffer), "%d-%d-%d %d:%d:%d",\
        curr->tm_year + 1900, curr->tm_mon + 1, curr->tm_mday,\
        curr->tm_hour, curr->tm_min, curr->tm_sec);
        return time_buffer;
    }
    std::ostream& Log(const std::string level, const std::string& file_name, int line) {
        std::string header = "[" + level + "][" + TimeStampToLocalTime(time(nullptr))\
         + "][" + file_name + ": " + std::to_string(line) + "]"; 
        std::cout << header;
        return std::cout;
    }

    #define LOG(level) Log(#level, __FILE__, __LINE__)
